import json
from backend import *
import backend
from flask import Flask
from flask import request
from flask import redirect
from flask import jsonify
app = Flask(__name__)


@app.route('/', methods=['POST', 'GET'])
def index0():
    return '<h1>TEST</h1>'


@app.route('/api/getJigsaw', methods=['POST'])
def index1():
    if request.method == 'POST':
        a = request.get_data()
        return getJigsaw(a)

@app.route('/api/findPieces', methods=['POST'])
def index2():
    if request.method == 'POST':
        a = request.get_data()
        return findPieces(a)

@app.route('/api/getAllInfo', methods=['POST'])
def allInfo():
    if request.method == 'POST':
        a = request.get_data()
        return getAllInfo(a)


@app.route('/api/markPiece', methods=['POST'])
def index3():
    if request.method == 'POST':
        a = request.get_data()
        return markPiece(a)

@app.route('/api/catchPiece', methods=['POST'])
def index4():
    if request.method == 'POST':
        a = request.get_data()
        return catchPiece(a)



@app.route('/user/<name>')
def user(name):
    return'<h1>hello, %s</h1>' % name

if __name__ == '__main__':
    app.run(debug=True, host='0.0.0.0')
